
<template>
  <div style="width: 80% ;text-align: center"  >
    <div style="margin-bottom: 30px"> 编辑用户</div>
    <el-form :inline="true" :model="form.user"  style="width: 90% "  label-width="100px">
      <el-form-item label="卡号">
        <el-input v-model="form.username" disabled placeholder="卡号">请输入姓名</el-input>
      </el-form-item>
      <el-form-item label="姓名">
        <el-input v-model="form.name" placeholder="姓名">请输入姓名</el-input>
      </el-form-item>
      <el-form-item label="年龄">
        <el-input v-model="form.age" placeholder="年龄">请输入年龄</el-input>
      </el-form-item>
      <el-form-item label="性别">
        <el-input v-model="form.sex" placeholder="性别">请输入性别</el-input>
      </el-form-item>
      <el-form-item label="电话">
        <el-input v-model="form.phone" placeholder="电话">请输入电话</el-input>
      </el-form-item>
      <el-form-item label="地址">
        <el-input v-model="form.address" placeholder="地址">请输入地址</el-input>
      </el-form-item>

    </el-form>
    <div  style="text-align: center; margin-top: 30px">
      <el-button type="primary" @click="save" size="medium" > 提交</el-button>

    </div>
  </div>
</template>
<script>
import request from "@/utils/request";
export default {
  name: "EditUser",
  data() {

    return {
      form: {
        name:'',
        age:'',
        sex:'',
        phone:'',
        address:'',
        username:''
      }
    }
  },
  created() {
    const id=this.$route.query.id
    // 注意是route不是router
    request.get("/user/"+id).then(res =>{
      this.form=res.data
      console.log(res.data)

    })
  },
  methods:
      {
        save()
        {
          request.put('/user/update',this.form).then(res => {
            if(res.code ==="200")
            {
              this.$notify.success('修改成功')
               this.$router.push("/user")


            }
            else
            {
              this.$notify.error('res.msg')
            }
          })
        }

      }

}

</script>


<style scoped>

</style>


<style scoped>

</style>